package com.st.warehouse.global.sharedpreferences;

import android.content.Context;
import android.content.SharedPreferences;


/**
 * 全局store
 */
public class STSharedPreferences {

    private final static String  SHARE_NAME = "ST_USER";
    private final int SHARE_MODE = 0;
    private static SharedPreferences shared;
    private Context context = null;


    private static STSharedPreferences stp;
    private STSharedPreferences() {}

    public static STSharedPreferences getInstance(Context mContext) {
        if(stp == null) {
            stp = new STSharedPreferences();
            shared = mContext.getApplicationContext().getSharedPreferences(SHARE_NAME, Context.MODE_PRIVATE);
        }
        return stp;
    }


    /**
     * 保存map-settings
     * @param settings
     */
    public void saveMapSettings(String settings) {
        shared.edit().putString("settings", settings).commit();
    }

    /**
     * 获取map-settings
     * @return
     */
    public String getMapSettings() {
        return shared.getString("settings","");
    }

    /**
     * 保存关注选项-followOptions
     * @param followOptions
     */
    public void saveFollowOptions(String followOptions) {
        shared.edit().putString("followOptions", followOptions).commit();
    }

    /**
     * 获取关注选项-followOptions
     * @return
     */
    public String getFollowOptions() {
        return shared.getString("followOptions","");
    }


    public void saveUser(String user) {
        shared.edit().putString("username", user).commit();
    }
    public void savePass(String pass) {
        shared.edit().putString("password", pass).commit();
    }

    public String getUser() {
        return shared.getString("username", "");
    }
    public String getPass() {
        return shared.getString("password", "");
    }

    public void clearSharedpreferencesData(){
        shared.edit().clear().commit();
    }

}
